package com.huluobo.h3kotlinproject.demo

import com.huluobo.h3kotlinproject.R
import com.huluobo.h3kotlinproject.base.BaseMVVMActivity
import com.huluobo.h3kotlinproject.databinding.ActivityRoomBinding

class RoomActivity : BaseMVVMActivity<ActivityRoomBinding>() {
    private val appDataBase = Utils.getAppDatabase()
    private val userDao = appDataBase.getUserDao()
    override fun initData() {

    }

    override fun initView() {
        dataBinding.demoInsert.setOnClickListener {
            userDao.insertUser(
                User(
                    0,
                    dataBinding.demoEtId.text.toString(),
                    dataBinding.demoEtUsername.text.toString(),
                    1
                )
            )

            dataBinding.demoQuery.setOnClickListener {
                dataBinding.user =
                    Utils.getAppDatabase().getUserDao().queryUser(dataBinding.demoEtId.text.toString())
            }
        }

    }

    override fun getLayoutId(): Int = R.layout.activity_room
}